public class JsonPathExpectationsHelper
extends java.lang.Object
Based on the JsonPath project: requiring version 0.9+, with 1.1+ strongly recommended.
Modifier and Type | Field and Description |
---|---|
private static java.lang.reflect.Method |
compileMethod |
private static java.lang.Object |
emptyFilters |
private java.lang.String |
expression |
private JsonPath |
jsonPath |
Constructor and Description |
---|
JsonPathExpectationsHelper(java.lang.String expression,
java.lang.Object... args)
Construct a new JsonPathExpectationsHelper.
|
Modifier and Type | Method and Description |
---|---|
<T> void |
assertValue(java.lang.String content,
<any> matcher)
Evaluate the JSON path and assert the resulting value with the given
Matcher . |
void |
assertValue(java.lang.String responseContent,
java.lang.Object expectedValue)
Apply the JSON path and assert the resulting value.
|
void |
assertValueIsArray(java.lang.String responseContent)
Apply the JSON path and assert the resulting value is an array.
|
void |
doesNotExist(java.lang.String content)
Evaluate the JSON path and assert it doesn't point to any content.
|
private java.lang.Object |
evaluateJsonPath(java.lang.String content) |
void |
exists(java.lang.String content)
Evaluate the JSON path and assert the resulting content exists.
|
private static java.lang.reflect.Method compileMethod
private static java.lang.Object emptyFilters
private final java.lang.String expression
private final JsonPath jsonPath
public JsonPathExpectationsHelper(java.lang.String expression, java.lang.Object... args)
expression
- the JsonPath expressionargs
- arguments to parameterize the JSON path expression with
formatting specifiers defined in String.format(String, Object...)
public <T> void assertValue(java.lang.String content, <any> matcher) throws java.text.ParseException
Matcher
.content
- the response contentmatcher
- the matcher to assert on the resulting json pathjava.text.ParseException
private java.lang.Object evaluateJsonPath(java.lang.String content) throws java.text.ParseException
java.text.ParseException
public void assertValue(java.lang.String responseContent, java.lang.Object expectedValue) throws java.text.ParseException
java.text.ParseException
public void assertValueIsArray(java.lang.String responseContent) throws java.text.ParseException
java.text.ParseException
public void exists(java.lang.String content) throws java.text.ParseException
java.text.ParseException
public void doesNotExist(java.lang.String content) throws java.text.ParseException
java.text.ParseException